package cn.sccdlg.ssm.dao;

import cn.sccdlg.ssm.domain.Account;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author RaoShuang
 * @emil 991207823@qq.com
 * @date 2020/10/24 23:04
 * 帐户dao接口
 */
@Repository
public interface AccountDao {

    // 查询所有账户
    @Select("select * from account")
    List<Account> findAll();

    // 保存帐户信息
    @Insert("insert into account (name, money) values (#{name}, #{money})")
    void saveAccount(Account account);

    @Update("update account set name = #{name}, money = #{money} where id = #{id}")
    void updateAccount(Account account);

    /**
     * 查询单个账户信息
     */
    @Select("select id, name, money from account where id = #{id}")
    Account findOne(Integer id);

}
